package com.bizdk.fastfx.model;

import com.bizdk.fastfx.domain.entity.Doctor;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;

public class DoctorModel {
    private StringProperty id = new SimpleStringProperty("");
    private StringProperty name = new SimpleStringProperty("");
    private StringProperty passwd = new SimpleStringProperty("");
    private StringProperty title = new SimpleStringProperty("");

    private boolean create;

    public DoctorModel() {
    }

    public DoctorModel(String id, String name, String passwd, String title) {
        setId(id);
        setName(name);
        setPasswd(passwd);
        setTitle(title);
    }

    public DoctorModel(Doctor entity) {
        setId(entity.getId());
        setName(entity.getName());
        setPasswd(entity.getPassword());
        setTitle(entity.getTitle());
    }

    public String getId() {
        return id.get();
    }

    public void setId(String id) {
        this.id.set(id);
    }

    public String getName() {
        return name.get();
    }

    public void setName(String name) {
        this.name.set(name);
    }

    public String getPasswd() {
        return passwd.get();
    }

    public StringProperty passwdProperty() {
        return passwd;
    }

    public void setPasswd(String passwd) {
        this.passwd.set(passwd);
    }

    public String getTitle() {
        return title.get();
    }

    public void setTitle(String title) {
        this.title.set(title);
    }

    public boolean isCreate() {
        return create;
    }

    public void setCreate(boolean create) {
        this.create = create;
    }

    public Doctor toDoctor() {
        Doctor entity = new Doctor();
        entity.setId(getId());
        entity.setName(getName());
        entity.setPassword(getPasswd());
        entity.setTitle(getTitle());
        return entity;
    }

    public static DoctorModel fromDoctor(Doctor doctor) {
        if (null == doctor) {
            return null;
        }
        return new DoctorModel(doctor);
    }
}
